package com.diaohw.module.file.mapper;

import cn.hutool.core.util.StrUtil;
import com.diaohw.module.file.obj.entity.FileDO;
import com.diaohw.module.file.obj.query.FileQuery;
import com.diaohw.module.file.obj.tables.FileDef;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;
/**
 * 文件信息 映射层。
 *
 * @author D-Hw
 * @since 2024-11-22 17:21:01
 */
@Mapper
public interface FileMapper extends BaseMapper<FileDO> {


    static QueryWrapper createWrapper(FileQuery query){
       QueryWrapper wrapper = QueryWrapper.create();
       wrapper.and(FileDef.FILE.EXT.like(query.getExt()).when(StrUtil.isNotBlank(query.getExt())));
       wrapper.and(FileDef.FILE.MD5.like(query.getMd5()).when(StrUtil.isNotBlank(query.getMd5())));
       wrapper.and(FileDef.FILE.OCR.like(query.getOcr()).when(StrUtil.isNotBlank(query.getOcr())));
       wrapper.and(FileDef.FILE.PATH.like(query.getPath()).when(StrUtil.isNotBlank(query.getPath())));
       wrapper.and(FileDef.FILE.BUCKET.like(query.getBucket()).when(StrUtil.isNotBlank(query.getBucket())));
       wrapper.and(FileDef.FILE.STATUS.like(query.getStatus()).when(StrUtil.isNotBlank(query.getStatus())));
       wrapper.and(FileDef.FILE.FILENAME.like(query.getFilename()).when(StrUtil.isNotBlank(query.getFilename())));
       wrapper.and(FileDef.FILE.SOURCE_ID.like(query.getSourceId()).when(StrUtil.isNotBlank(query.getSourceId())));
       wrapper.and(FileDef.FILE.CONTENT_TYPE.like(query.getContentType()).when(StrUtil.isNotBlank(query.getContentType())));
       return wrapper;
   }
}
